package com.bootdo.wx.service.impl;

import com.bootdo.common.utils.PageHelperUtils;
import com.bootdo.common.utils.StringUtils;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.bootdo.wx.dao.OrderComentDao;
import com.bootdo.wx.domain.OrderComentDO;
import com.bootdo.wx.service.OrderComentService;



@Service
public class OrderComentServiceImpl implements OrderComentService {
	@Autowired
	private OrderComentDao orderComentDao;
	
	@Override
	public OrderComentDO get(String id){
		return orderComentDao.get(id);
	}
	
	@Override
	public List<OrderComentDO> list(Map<String, Object> map){
		return orderComentDao.list(map);
	}
	
	@Override
	public int count(Map<String, Object> map){
		return orderComentDao.count(map);
	}
	
	@Override
	public int save(OrderComentDO orderComent){
		return orderComentDao.save(orderComent);
	}
	
	@Override
	public int update(OrderComentDO orderComent){
		return orderComentDao.update(orderComent);
	}
	
	@Override
	public int remove(String id){
		return orderComentDao.remove(id);
	}
	
	@Override
	public int batchRemove(String[] ids){
		return orderComentDao.batchRemove(ids);
	}

	@Override
	public PageInfo<Map<String,Object>> getComentByGoods(Map<String, Object> params) {
		PageHelperUtils.page(params);
		List<Map<String,Object>> list = orderComentDao.getComentByGoods(params);
		for (Map<String,Object> map : list) {
			String imgurls = StringUtils.getString(map.get("imgurls"));
			List<String> imgList = new ArrayList<String>();
			if (!imgurls.equals("")) {
				String [] imgs = imgurls.split(",");
				for (int i = 0; i<imgs.length; i++) {
					imgList.add(imgs[i]);
				}
			}
			map.put("imgList",imgList);
		}
		PageInfo<Map<String,Object>> pageInfo = new PageInfo<>(list);
		return pageInfo;
	}

	@Override
	public List<Map<String,Object>> getComentList(Map<String, Object> map) {
		return orderComentDao.getComentList(map);
	}

	@Override
	public int getComentListCount(Map<String, Object> map) {
		return orderComentDao.getComentListCount(map);
	}
	
}
